﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Yto.Common.Dependency;
using Yto.Entities;

namespace Yto.Repositories
{
    public interface IBaseRepository<TE> : IBaseRepository<TE, int> where TE : class, IEntity<int>
    {
    }

    public interface IBaseRepository<TE, TPK> : IBaseRepository where TE : class, IEntity<TPK>
    {

        TE Single(TPK id);

        TE Single(Expression<Func<TE, bool>> expression);

        IQueryable<TE> GetAll();

        TE Insert(TE entity);

        TE Update(TE entity);

        void Delete(TE entity);

        void Delete(TPK id);

        List<TE> GetList();

        List<TE> GetList(Expression<Func<TE, bool>> expression, int maxCount = 0);

        bool BatchInsert(IEnumerable<TE> list);

        bool DeleteAll();


        Task<TE> UpdateAsync(TE entity);

        Task DeleteAsync(TE entity);

        Task DeleteAsync(TPK id);

        Task<List<TE>> GetListAsync();

        Task<List<TE>> GetListAsync(Expression<Func<TE, bool>> expression, int maxCount = 0);

        Task<TE> InsertAsync(TE entity);

        Task<bool> BatchInsertAsync(IEnumerable<TE> list);
        Task<bool> DeleteAllAsync();

        TE FirstOrDefault(TPK id);

        TE FirstOrDefault(Expression<Func<TE, bool>> expression);

        Task<TE> FirstOrDefaultAsync(TPK id);

        Task<TE> FirstOrDefaultAsync(Expression<Func<TE, bool>> expression);
    }

    public interface IBaseRepository : ITransient
    {
    }
}
